package com.atguigu.day06.HomeWork;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/11/5 18:39
 * @注释
 */
public class HomeWork2 {
    public static int maxInArray(int[] arr){
        int max = arr[0];
        for(int i = 1; i < arr.length; i++){
            if(arr[i] > max){
                max = arr[i];
            }
        }
        return max;
    }
    public static int minInArray(int[] arr){
        int min = arr[0];
        for(int i = 1; i < arr.length; i++){
            if(arr[i] < min){
                min = arr[i];
            }
        }
        return min;
    }
    public static void main(String[] args) {
        int[] arr = new int[10];
        for(int i = 0; i < arr.length; i++){
            arr[i] = (int)(Math.random()*100);
        }
        System.out.println("最大值是: " + maxInArray(arr));
        System.out.println("最小值是: " + minInArray(arr));
    }
}
